package com.come4loves.game.module.skill.skillcardimpl;

import org.springframework.stereotype.Component;

import com.come4loves.core.utils.Splitable;
import com.come4loves.game.module.card.constant.CardType;
import com.come4loves.game.module.fight.action.BatchAction;
import com.come4loves.game.module.fight.action.ChangeUnitAction;
import com.come4loves.game.module.fight.model.FightCard;
import com.come4loves.game.module.fight.model.FightContext;
import com.come4loves.game.module.skill.AbstractSkillCardParser;
import com.come4loves.game.module.skill.model.SkillModel;
@Component
public class MorfUnitSkill extends AbstractSkillCardParser {

	@Override
	public String skillId() {
		return "morfunit";
	}

	@Override
	public void handerSkill(FightCard attackerCard, FightCard targetCard, SkillModel skillModel, BatchAction batchAction, FightContext fightContext) {
		String[] temp = skillModel.getEffect().get(skillId()).split(Splitable.BETWEEN_DOT);
		for (String uid : temp) {
			FightCard card = FightCard.valueOf(CardType.UNIT, Integer.valueOf(uid));
			targetCard.setCfgId(card.getCfgId());
			targetCard.setAttack(card.getAttack());
			targetCard.setHp(card.getHp());
			targetCard.setMaxHp(card.getHp());
			targetCard.setMagic(card.getMagic());
			targetCard.setSpeed(card.getSpeed());
			targetCard.getCastTargets().clear();
			targetCard.getCastTargets().putAll(card.getCastTargets());
			targetCard.getSkills().clear();
			targetCard.getSkills().putAll(card.getSkills());
			ChangeUnitAction changeUnitAction = new ChangeUnitAction(targetCard);
			batchAction.addAction(changeUnitAction);
		}
	}

}
